<?php

class ModulesDao extends vDao {
    
    function retrieveList() {
        $sql = "select * from ".DB_PREF."modules";
        return $this->pdio->query($sql);
    }
    
    function isInstalled($modname) {
        $sql = "select name from ".DB_PREF."modules where name=:modname";
        $data = array(':modname' => $modname);
		
		$res = $this->pdio->parametricQuery($sql, $data);

		
		if (count($res) == 0) {
		    return false;
		}
		
		return true;
        
    }
    
    function install($modname) {
        $sql = "INSERT INTO ".DB_PREF."modules (`name`, `order`) VALUES ('$modname', '0')";
        if ($this->pdio->query($sql)) {
            return true;
        }
        return false;
    }
    
    
    function uninstall($modname) {
        $sql = "DELETE FROM ".DB_PREF."modules WHERE `name` = '$modname';";
        if ($this->pdio->query($sql)) {
            return true;
        }
        return false;
    }    
    
    
}